﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Auto.AlgsAndPush.DTO;
using Newtonsoft.Json;

namespace Auto.AlgsAndPush.Services.DeviceType
{
    public class HydroType : BaseDeviceType
    {
        public HydroType(HttpClientService httpClient) : base(httpClient) { }

        public override async Task<List<OriginResult>> PullMultiNumberResultsAsync(int prjId, DateTime startTime, DateTime endTime)
        {
            try
            {
                var url = $"http://autohydro/auto/projects/{prjId}/height?start={startTime}&end={endTime}";
                return await GetOriginResultsAsync(url);
            }
            catch
            {
                throw new Exception($"静力水准--测组{prjId}获取多期数据出错！");
            }
        }

        public override async Task<bool> PushFilterResultAsync(int prjId, FilterResult filterResult)
        {
            try
            {
                var url = $"http://autohydro/auto/projects/{prjId}/height/filterresult";
                var rets = await UploadFilterResult(url, filterResult);
                return rets;
            }
            catch
            {
                throw new Exception($"静力水准--测组{prjId}上传滤波数据失败！");
            }
        }
    }
}
